﻿#if UNITY_EDITOR
using System;
using UnityEngine;
/// <summary>
/// Xlsx表配置设定
/// </summary>
class EditorWindowSFXLSXConfigSetting : AbsESF_EditorWindow
{
    /// <summary>
    /// 节点
    /// </summary>
    ESF_CollectAsset_XLSX mNode = null;

    protected override AbsESF_EditorBuildAsset config => mNode != null ? mNode.xlsxTableSchemaXmlConfig : null;

    /// <summary>
    /// 设置数据
    /// </summary>
    /// <param name="_node">节</param>
    public void SetData(ESF_CollectAsset_XLSX _node)
    {
        mNode = _node;
        ESF_Utility.PingObject(mNode.xlsxTableSchemaXmlConfig.filePath);
    }

    protected override void OnRunGUI()
    {
        if (mNode != null)
        {
            if (GUILayout.Button(ESF_enGUIDisplayWord.Save.ESF_ToAlias()))
            {
                OnSaveConfig();
            }
            if (GUILayout.Button($"{ESF_enGUIDisplayWord.Query.ESF_ToAlias()}{ESF_enGUIDisplayWord.Data.ESF_ToAlias()}"))
            {
                EditorWindowSFXLSXConfigQueryData query = GetWindow<EditorWindowSFXLSXConfigQueryData>();
                query.SetData(mNode);
                query.Show();
            }
            if (GUILayout.Button($"{ESF_enGUIDisplayWord.Resolver.ESF_ToAlias()} Xlsx表架构"))
            {
                ESF_Logic.ResolveXlsxSchema(mNode);
                ESF_Utility.ExecuteMenuAssetsRefresh();
            }
            if (GUILayout.Button($"{ESF_enGUIDisplayWord.Build.ESF_ToAlias()} Xlsx表脚本"))
            {
                ESF_Logic.BuildXlsxScript(mNode);
                ESF_Utility.ExecuteMenuAssetsRefresh();
            }
            if (GUILayout.Button($"{ESF_enGUIDisplayWord.Build.ESF_ToAlias()} Xlsx表数据库"))
            {
                ESF_Logic.BuildXlsxDbMaster(mNode);
                ESF_Utility.ExecuteMenuAssetsRefresh();
            }
        }        
    }
}
#endif
